package top.oylan.manager.service;

import org.springframework.stereotype.Service;
import top.oylan.manager.entity.Types;
import top.oylan.manager.entity.example.TypesExample;
import top.oylan.manager.entity.extend.TypesExtend;
import top.oylan.manager.mapper.TypesMapper;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author abduahad
 * @Description ${description}
 * @Date 2019-05-26
 */
@Service
public class TypeServiceImpl implements TypeService {

    @Resource
    TypesMapper mapper;

    @Override
    public List<Types> selectAll() {
        TypesExample example = new TypesExample();
        TypesExample.Criteria criteria = example.createCriteria();
        return mapper.selectByExample(example);
    }

    @Override
    public void updateTypes(Types types) {
        TypesExample example = new TypesExample();
        TypesExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(types.getId());
        mapper.updateByExampleSelective(types,example);
    }

    @Override
    public void deleteTypes(Integer id) {
        TypesExample example = new TypesExample();
        TypesExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(id);
        mapper.deleteByExample(example);
    }

    @Override
    public void insertTypes(Types types) {
        mapper.insertSelective(types);
    }

    @Override
    public Types findById(Integer id) {

        return mapper.findById(id);
    }

    //**  for api **/
    @Override
    public ArrayList<TypesExtend> selectVideoTypeCategory() {
        return mapper.selectVideoTypeCategory();
    }

    @Override
    public Types selectCourseCategories() {

        return mapper.selectCourseCategories();
    }
}
